package com.lf.web.controller;

import com.lf.web.service.ServiceSupport;
import com.opensymphony.xwork2.ActionSupport;
import org.apache.struts2.util.ServletContextAware;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.ServletContext;

public class IndexController extends ActionSupport implements ServletContextAware {

    private WebApplicationContext wac;
    private ServiceSupport cs;
    private String act = "";

    public void setAct(String act) {
        this.act = act;
    }

    public void setServletContext(ServletContext servletContext) {
        wac = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
    }

    public String execute() {
        cs = (ServiceSupport) wac.getBean("IndexService");
        String rsstr = cs.execute();
        return rsstr;
    }
}
